package com.baor.controller;

import com.baor.service.DeliveryRecordService;
import com.baor.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController // 修改为RestController
@RequestMapping(value = "/delivery")
public class DeliveryRecordController {

    //投递记录
    @Autowired
    private DeliveryRecordService deliveryRecordService;

    @RequestMapping(value = "deliverylist")
    public R InformationList(@RequestBody Map<String,Object> params){
        return deliveryRecordService.deliveryRecordList(params);
    }

    @RequestMapping(value = "update")
    public R updateDeliveryRecord(@RequestBody Map<String,Object> params){
        return deliveryRecordService.updateDeliveryRecord(params);
    }

//    @RequestMapping(value = "update2")
//    public R updateDeliveryRecord2(@RequestBody Map<String,Object> params){
//        return deliveryRecordService.updateDeliveryRecord2(params);
//    }

    /**
     * 修改投递记录（支持照片上传）
     * 注意：前端需用multipart/form-data格式提交
     */
    @RequestMapping(value = "/update2", method = RequestMethod.POST)
    public R updateDeliveryRecord2(
            @RequestParam Map<String, Object> params,  // 普通参数
            @RequestParam(value = "files", required = false) MultipartFile[] files) {  // 照片文件
        return deliveryRecordService.updateDeliveryRecord2(params, files);
    }

    @RequestMapping(value = "/details")
    public  R details(@RequestBody Map<String,Object> params){
        return deliveryRecordService.details(params);
    }

}